#coding=utf-8
import requests,json,urllib

def login(url):
    login_headers = {'Referer': 'http://op.' + url, 'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
                     'Upgrade-Insecure-Requests': '1', 'Content-Type': 'application/x-www-form-urlencoded',
                     'Accept-Encoding': 'gzip, deflate',
                     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0',
                     'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
    if url == 'yipaiwang.co':
        adminname = u'陈强'
        password = 'cq123321'
    if url == 'yipaiwang.cc':
        adminname = u'陈强'
        password = 'cq123321'
    if url == 'yidai.co':
        adminname = 'WD108472'
        password = 'jk123123'
    if url == 'yidaip2p.net':
        adminname = u'smilesoul'
        password = 'cq123321'
    if url == 'yipaiwang.com':
        adminname = u'李一牧'
        password = '198672134z'
    userinformation = {'adminname': adminname, 'password': password, 'authCode': '123456'}
    s = requests.session()
    login = s.post('http://op.' + url, data=userinformation, headers=login_headers, verify=False)
    login1 = str(login)
    if u"登录成功" in login.text:
        print login1 + u"登录成功"
        # 0代表登录成功
        return '0',s,login.cookies,login_headers
    else:
        # 1代表登录失败
        return '1',s,login.cookies,login_headers